<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Person</title>
	<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
	
  </head>
  
  <body style="text-align: center;">
    	
    	
    	<br>
    	<form action="Person_userRegister.action" method="post">
	    	<table align="center" border="1" width="35%">
	    		<tr>
	    			<td colspan="3" align="center">Person注册</td>
	    		</tr>
	    		<tr>
	    			<td align="center" width="15%">username</td>
	    			<td width="40%"><input type="text" name="username"> </td>
	    			<td> &nbsp;${username } </td>
	    		</tr>
	    		<tr>
	    			<td align="center">password</td>
	    			<td><input type="password" name="password"> </td>
	    			<td>&nbsp;${password }</td>
	    		</tr>
	    		<tr>
	    			<td align="center">sex</td>
	    			<td><input type="radio" name="sex" value="男" checked="checked">男&nbsp;<input type="radio" name="sex" value="女">女 </td>
	    			<td>&nbsp;</td>
	    		</tr>
	    		<tr>
	    			<td align="center">age</td>
	    			<td><input type="text" name="age"> </td>
	    			<td>&nbsp;${age }</td>
	    		</tr>
	    		<tr>
	    			<td>&nbsp;</td>
	    			<td colspan="2"><input type="submit" value="提交"> </td>
	    		</tr>
		    	<tr>
		    		<td colspan="3" align="center" style="color:red;">
		    			&nbsp;${result}
		    		</td>
		    	</tr>
	    		
	    	</table>
    	</form>
    	
    	<br>
    		<script type="text/javascript">
    			$(function(){
    				$("#queryPerson").click(function(){
	    				var name = $('#name1').val();
		    			if(name!=""){
		    				$.ajax({
		    					type:"post",
		    					url:"Person-userQuery.action",
		    					data:"idd="+name+"&point=222",
		    					dataType:"text",
		    					success:function (msg){
		    						//解析json数据
		    						var ajaxObj = eval("(" +msg+ ")");
		    						//$("#queryTable").remove(tr0);
		    						var tr0 = "<tr> <td>Id</td><td>"+ ajaxObj.id +"<td> </tr>"+
		    								  "<tr> <td>username</td><td>"+ ajaxObj.username +"<td> </tr>"+
		    								  "<tr> <td>password</td><td>"+ ajaxObj.password +"<td> </tr>"+
		    						 		  "<tr> <td>sex</td><td>"+ ajaxObj.sex +"<td> </tr>"+
		    						 		  "<tr> <td>age</td><td>"+ ajaxObj.age +"<td> </tr>";
		    						$("#queryTable").append(tr0);
		    						//alert(ajaxObj.age);
		    					},
		    					error:function(){
		    						alert("error");
		    					}	
		    				});
		    			}else{
		    				alert("请输入username");
		    			}
	    			});
    			});
    			
    		</script>
	    	<table align="center" border="1" width="35%" id="queryTable">
	    		<tr>
	    			<td colspan="2" align="center">查询person的基本信息</td>
	    		</tr>
	    		<tr>
	    			<td width="60%"> <input type="text" name="userName" id="name1"> </td>
	    			<td> <input type="button" id="queryPerson" value="查询"> </td>
	    		</tr>
	    		
	    	</table>
    		<br>
    		<table align="center" border="1" width="35%">
    			<tr>
    				<td align="center"> <a href="Person_userQueryAll.action">查询所有的person信息</a> </td>
    			</tr>
    		</table>
    		<br>
    		<table>
    			<tr>
    			<td style="color:red;"> ${update } </td>
    			</tr>
    		</table>
    		
  </body>
</html>
